package de.gameduell.framework.facebook.reporting {

	import com.adobe.serialization.json.JSON;

	public class WebtrekkObject {

		private var webtrekk:Object;
		private var _appContext:String;
		private var _appType:String;

		public function WebtrekkObject(){
			webtrekk = new Object();
			trackDomain = "gameduell01.webtrekk.net";
			trackId = "814688243158900";
			domain = "fb.gameduell.net";
			appContext = "app_start";
			
			contentId = "";
			contentGroup = "";
			linkTrack = "1";
			customParameter = "";
			cookie = "";
			customerId = "";
			customSessionParameter = "";
			customTimeParameter = "";
			customClickParameter = "";
			mediaCode = "";
			mediaCodeValue = "";
		}
		
		// ################# REQUIRED PARAMETERS ############################
		
		public function set contentId(trackingInfo:String):void {
			webtrekk.contentId = appType + "." + appContext + "." + trackingInfo;
		}

		public function set trackDomain(aTrackDomain:String):void {
			webtrekk.trackDomain = aTrackDomain;
		}
		
		public function set trackId(aTrackId:String):void {
			webtrekk.trackId = aTrackId;
		}
		
		public function set domain(aDomain:String):void {
			webtrekk.domain = aDomain;
		}
		
		public function updateContentId():void {
			webtrekk.contentId = _appType + "." + _appContext;
		}

		public function get appContext():String {
			return _appContext;
		}
		
		public function set appContext(anAppContext:String):void {
			_appContext = anAppContext;
			updateContentId();
		}
		
		public function get appType():String {
			return _appType;
		}
		
		public function set appType(anAppType:String):void {
			_appType = anAppType;
			updateContentId();
		}
		
		// ################# OPTIONAL PARAMETERS ############################

		public function set contentGroup(aContentGroup:String):void {
			webtrekk.contentGroup = aContentGroup;
		}
		
		public function set linkTrack(aLinkTrack:String):void {
			webtrekk.linkTrack = aLinkTrack;
		}	
		
		public function set customParameter(aCustomParameter:String):void {
			webtrekk.customParameter = aCustomParameter;
		}	

		public function set customerId(aCustomerId:String):void {
			webtrekk.customerId = aCustomerId;
		}	

		public function set cookie(aCookie:String):void {
			webtrekk.cookie = aCookie;
		}
		
		public function set customSessionParameter(aCustomSessionParameter:String):void {
			webtrekk.customSessionParameter = aCustomSessionParameter;
		}
		
		public function set customTimeParameter(aCustomTimeParameter:String):void {
			webtrekk.customTimeParameter = aCustomTimeParameter;
		}
		
		public function set customClickParameter(aCustomClickParameter:String):void {
			webtrekk.customClickParameter = aCustomClickParameter;
		}
		
		public function set mediaCode(aMediaCode:String):void {
			webtrekk.mediaCode = aMediaCode;
		}

		public function set mediaCodeValue(aMediaCodeValue:String):void {
			webtrekk.mediaCodeValue = aMediaCodeValue;
		}
		
		public function toJSON():String {
			return JSON.encode(webtrekk);
		}	
	}
}